<template>
  <el-dialog title="维保记录" width="1170px" :visible.sync="dialogTableVisible">
    <el-table :data="recordList" height="400" size="small" v-loading="loading">
      <el-table-column type="index" label="No" :index="indexMethod"></el-table-column>
      <el-table-column prop="type" label="维修/保养">
        <template slot-scope="scope" >
          {{scope.row.type == 1 ? "保养" : "维修" }}
        </template>
      </el-table-column>
      <el-table-column prop="endTime" label="维保时间">
        <template slot-scope="scope" >
          {{ scope.row.maintenanceTime | changeDate }}
        </template>
      </el-table-column>
      <el-table-column prop="unit" label="维养单位"></el-table-column>
      <el-table-column prop="approvalResults" label="维养结论"></el-table-column>
      <el-table-column prop="report" label="检定证书编号"></el-table-column>
      <el-table-column prop="repairman" label="登记人"></el-table-column>
      <el-table-column prop="createTime" label="登记时间">
        <template slot-scope="scope" >
          {{scope.row.createTime | changeDate}}
        </template>
      </el-table-column>
    </el-table>

    <Pagination :pageData="pageData" @pageNum="pageNumData" @pageSize="pageSizeData"></Pagination>
  </el-dialog>
</template>

<script>
import Pagination from "@/components/Pagination";
import HttpInterface from '../../util/httpInterface';

export default {
  components: {
    Pagination
  },
  data() {
    return {
      dialogTableVisible: false,
      loading: false,
      recordList: [],
      pageData: {
        total: 0,
        pageNum: 1,
        pageSize: 10
      },
    };
  },

  methods: {
    pageNumData (page) {
      this.pageData.pageNum = Number(page);
      this.getServiceRecordList();
    },

    pageSizeData (page) {
      this.pageData.pageSize = Number(page);
      this.getServiceRecordList();
    },

    indexMethod (index) {
      return index + 1;
    },

    getServiceRecordList(id) {
      this.loading = true;
      var _this = this
      var params = {
        page:_this.pageData.pageNum,
        size:_this.pageData.pageSize,
        mechanicalId: id
      }
      HttpInterface.requestGet(this,HttpInterface.URL_MAINTENANCE_RECORD_FIND_PAGE,params,function (res) {
        var data = res.data;
        _this.recordList = data.other.rows;
        _this.loading = false;
        _this.pageData.total = data.other.total;
      },function (err) {
        _this.loading = false;
        _this.errorMessage("获取数据失败！");
      })
    },

    show (id) {
      this.dialogTableVisible = true;
      this.getServiceRecordList(id);
    }
  }
};
</script>

<style  scoped>
.el-dialog__wrapper >>> .el-dialog{
  margin: 6% auto 60px !important;
}

.el-dialog__wrapper >>> .el-dialog__body{
  padding: 10px 20px;
}

.pic {
  width: 40px;
  height: 40px;
  border-radius: 4px;
}
</style>
